<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>2017.4.18 router</title>
    <script src="./vue.js"></script>
    <script src="./vue-router.js"></script>
</head>
<body>
<div id="app">
    <h1>router</h1>
    <p>
        <router-link to="/foo" tag="li">foo</router-link>
        <router-link to="/bar">bar</router-link>
        <router-link to="/username/use">usename</router-link>
    </p>
    <router-view></router-view>
</div>
<script>
    const Foo = {
        template:'<div>foo</div>'
    };
    const Bar = {
        template:'<div>bar</div>'
    };
    const Username = {
        template:'<div>{{$route.params.id}}</div>'
    };

    const routes = [
        {path:'/foo',component:Foo},
        {path:'/bar',component:Bar},
        {path:'/username/:id',component:Username}

    ];
    const router = new VueRouter({
        routes:routes
    });
    const app  = new Vue({
        router
    }).$mount('#app')
</script>
</body>
</html>